# -*- mode: python; coding: utf-8; -*-
##--------------------------------------------------------------------------##
##
## Copyright (C) 1998-2003 Markus Oberhumer <markus@oberhumer.com>
## Copyright (C) 2003 Mt. Hood Playing Card Co.
## Copyright (C) 2005-2010 Skomoroh <skomoroh@users.sourceforge.net>
## Copyright (C) 2010-2013 Jeremy Austin-Bardo <tjaustinbardo@gmail.com>
##
## This program is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program.  If not, see <http://www.gnu.org/licenses/>.
##
##--------------------------------------------------------------------------##
__all__ = []

from .. import comparecards as cmp_cards
from .. import pilelib as stack
from ..packlib import info as cs


class Waterfall_Foundation(stack.FromRowStackBuildMethod,
                           stack.AbstractFoundation):

    def isSequence(self, cards):
        """
        _sequence(cards:tup) -> bool

        :param tuple cards: cards to accept from another pile
        :return: cards acceptable?
        :rtype: boolean
        """
        if self.TOPCARD and self.TOPCARD['rank'] == cs.RAJA:
            return cmp_cards.isSuitSequence(cards, mod=12, dir=self.cap['dir'])
        return cmp_cards.isSameSuitSequence(cards, **self.cap)


class Dashavatara_ReserveStack(stack.ReserveStack):

    def cardsBuild(self, from_stack, cards):
        return (super(Dashavatara_ReserveStack, self).cardsBuild(from_stack,
                      cards)
                and self.game.s['talon'].cards)